package leetcode.median;

/**
 * ClassName: $238_ProductExceptSelf
 * Description:
 * date: 2022-02-20 16:04
 *
 * @author liyifan
 */
public class $238_ProductExceptSelf {
    public int[] productExceptSelf(int[] nums) {
        int len = nums.length;
        int[] left = new int[len];
        int[] right = new int[len];
        left[0] = 1;
        right[len - 1] = 1;
        for(int i = 1;i < len;i++){
            left[i] = left[i - 1] * nums[i - 1];
        }
        for(int i = len - 2;i >= 0;i--){
            right[i] = right[i + 1] * nums[i + 1];
        }
        int[] res = new int[len];
        for(int i = 0;i < len;i++){
            res[i] = left[i] * right[i];
        }
        return res;
    }
}
